Option Explicit On 
Option Strict On

Public Class frmVouchers
    Inherits System.Windows.Forms.Form
    Public Shared sVoucher As String = ""
    Public Shared oVcon As ContactInfo
    Public Shared iConType As Integer = 0
    Friend WithEvents button_example As System.Windows.Forms.Button
    Public Shared bUpdate As Boolean = False


#Region " Windows Form Designer generated code "

    Public Sub New(ByVal sSpec As String, ByVal VouchCon As ContactInfo, ByVal iContact As Integer)
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        sVoucher = sSpec
        oVcon = VouchCon
        iConType = iContact

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip
    Friend WithEvents cboxSpecimen As System.Windows.Forms.ComboBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents txtRepository As System.Windows.Forms.TextBox
    Friend WithEvents btnEdit As System.Windows.Forms.Button
    Friend WithEvents btnOK As System.Windows.Forms.Button
    Friend WithEvents btnCancel As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmVouchers))
        Me.Label1 = New System.Windows.Forms.Label
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.cboxSpecimen = New System.Windows.Forms.ComboBox
        Me.txtRepository = New System.Windows.Forms.TextBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.btnEdit = New System.Windows.Forms.Button
        Me.btnOK = New System.Windows.Forms.Button
        Me.btnCancel = New System.Windows.Forms.Button
        Me.button_example = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.Location = New System.Drawing.Point(12, 9)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(100, 23)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Specimen"
        Me.ToolTip1.SetToolTip(Me.Label1, "Select from list or type in your own specimen description")
        '
        'ToolTip1
        '
        Me.ToolTip1.IsBalloon = True
        Me.ToolTip1.ShowAlways = True
        Me.ToolTip1.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info
        '
        'cboxSpecimen
        '
        Me.cboxSpecimen.Items.AddRange(New Object() {"herbarium specimens", "blood samples", "photographs", "individuals"})
        Me.cboxSpecimen.Location = New System.Drawing.Point(15, 25)
        Me.cboxSpecimen.Name = "cboxSpecimen"
        Me.cboxSpecimen.Size = New System.Drawing.Size(230, 21)
        Me.cboxSpecimen.TabIndex = 5
        Me.ToolTip1.SetToolTip(Me.cboxSpecimen, "Select from list or type in your own specimen description")
        '
        'txtRepository
        '
        Me.txtRepository.Location = New System.Drawing.Point(15, 75)
        Me.txtRepository.Name = "txtRepository"
        Me.txtRepository.ReadOnly = True
        Me.txtRepository.Size = New System.Drawing.Size(230, 20)
        Me.txtRepository.TabIndex = 7
        Me.txtRepository.TabStop = False
        Me.ToolTip1.SetToolTip(Me.txtRepository, "Contact information for the curator or agency responsible for the specimens.")
        '
        'Label2
        '
        Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.Location = New System.Drawing.Point(12, 58)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(100, 23)
        Me.Label2.TabIndex = 6
        Me.Label2.Text = "Repository"
        Me.ToolTip1.SetToolTip(Me.Label2, "Contact information for the curator or agency responsible for the specimens.")
        '
        'btnEdit
        '
        Me.btnEdit.Image = Global.MetaDoc.My.Resources.Resources.file_edit_16x16
        Me.btnEdit.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.btnEdit.Location = New System.Drawing.Point(251, 73)
        Me.btnEdit.Name = "btnEdit"
        Me.btnEdit.Size = New System.Drawing.Size(75, 23)
        Me.btnEdit.TabIndex = 8
        Me.btnEdit.Text = "Edit"
        '
        'btnOK
        '
        Me.btnOK.Enabled = False
        Me.btnOK.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnOK.Image = Global.MetaDoc.My.Resources.Resources.Ok_16x16
        Me.btnOK.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.btnOK.Location = New System.Drawing.Point(170, 113)
        Me.btnOK.Name = "btnOK"
        Me.btnOK.Size = New System.Drawing.Size(75, 23)
        Me.btnOK.TabIndex = 9
        Me.btnOK.Text = "OK"
        Me.btnOK.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'btnCancel
        '
        Me.btnCancel.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnCancel.Image = Global.MetaDoc.My.Resources.Resources.Cancel_16x16
        Me.btnCancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.btnCancel.Location = New System.Drawing.Point(251, 113)
        Me.btnCancel.Name = "btnCancel"
        Me.btnCancel.Size = New System.Drawing.Size(75, 23)
        Me.btnCancel.TabIndex = 10
        Me.btnCancel.Text = "Cancel"
        Me.btnCancel.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'button_example
        '
        Me.button_example.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.button_example.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.button_example.Image = Global.MetaDoc.My.Resources.Resources.app_help_48x48
        Me.button_example.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.button_example.Location = New System.Drawing.Point(251, 12)
        Me.button_example.Name = "button_example"
        Me.button_example.Size = New System.Drawing.Size(110, 48)
        Me.button_example.TabIndex = 21
        Me.button_example.Text = "EXAMPLE"
        Me.button_example.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        Me.button_example.UseVisualStyleBackColor = True
        '
        'frmVouchers
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(373, 147)
        Me.ControlBox = False
        Me.Controls.Add(Me.button_example)
        Me.Controls.Add(Me.btnCancel)
        Me.Controls.Add(Me.btnOK)
        Me.Controls.Add(Me.btnEdit)
        Me.Controls.Add(Me.txtRepository)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.cboxSpecimen)
        Me.Controls.Add(Me.Label1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "frmVouchers"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Vouchers"
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region

    Private Sub frmVouchers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim iSelIndex As Integer = 0
        If (sVoucher <> "") Then
            iSelIndex = cboxSpecimen.FindStringExact(sVoucher)
            If (iSelIndex = -1) Then
                cboxSpecimen.Text = sVoucher
            Else
                cboxSpecimen.SelectedIndex = iSelIndex
            End If
        End If

        If (oVcon.PrimaryPerson = True) Then
            txtRepository.Text = oVcon.Person
        Else
            txtRepository.Text = oVcon.Organization
        End If
    End Sub

    Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
        Dim frmVouchCon As New frmContact(oVcon, iConType)
        frmVouchCon.ShowDialog()
        If (frmVouchCon.bUpdate = True) Then
            oVcon = frmVouchCon.conInfo
            iConType = 2
            If (oVcon.PrimaryPerson = True) Then
                txtRepository.Text = oVcon.Person
            Else
                txtRepository.Text = oVcon.Organization
            End If
        End If
        validateOK()
    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        sVoucher = cboxSpecimen.Text
        bUpdate = True
        Me.Dispose()
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        bUpdate = False
        Me.Dispose()
    End Sub

    Private Sub cboxSpecimen_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboxSpecimen.SelectedIndexChanged
        validateOK()
    End Sub
    Private Sub validateOK()
        If cboxSpecimen.SelectedIndex = -1 Or txtRepository.Text.Trim() = "" Then btnOK.Enabled = False Else btnOK.Enabled = True
    End Sub

    Public Function getUpdated() As Boolean
        Return bUpdate
    End Function
    Public Function getVoucher() As String
        Return sVoucher
    End Function
    Public Function getVCon() As ContactInfo
        Return oVcon
    End Function

    Private Sub button_example_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button_example.Click
        Dim helpForm As dialog_help = New dialog_help("Vouchers")
        helpForm.ShowDialog()
    End Sub
End Class
